const fs = require("fs");
const process = require("process");

// 方式1：readFile
// let data = fs.readFileSync("./fs模块.pdf");
// fs.writeFileSync("./fs模块2.pdf", data);
// console.log(process.memoryUsage());   //  arrayBuffers: 285649

// 方式2：流失对象
// const rs = fs.createReadStream("./fs模块.pdf");
// const ws = fs.createWriteStream("./fs模块-2.pdf");
// rs.on("data", (chunk) => {
//   ws.write(chunk);
// });
// console.log(process.memoryUsage()); //  arrayBuffers: 10519

const rs = fs.createReadStream("./fs模块.pdf");
const ws = fs.createWriteStream("./fs模块-2.pdf");
rs.pipe(ws);
